package main

import (
	"fmt"
	"sub-app-server/config"
	"sub-app-server/proxy"
	"sub-app-server/server"
	"sync"
)

func run(server func(string), ports []int) bool {

	b := false

	for _, port := range ports {
		go server(fmt.Sprintf(":%d", port))
		b = true
	}
	return b

}

func main() {

	config.Lock = &config.LockStruct{
		Mux:     &sync.Mutex{},
		Count:   1,
		LockMap: make(map[int]*config.LockMapData, 1),
	}

	// 代理
	run(server.RunProxy, config.C.Proxy)

	// web
	run(server.WebServer, config.C.Server)

	proxy.LocalProxy(":8030")

	<-make(chan struct{})

}
